package kt.com.bilin.coin.bean

import android.os.Parcelable
import com.bilin.coin.bean.MyMillBean.RecordsBean.BlDeviceBean
import com.flyco.tablayout.listener.CustomTabEntity
import com.sunfusheng.marqueeview.IMarqueeItem
import kotlinx.android.parcel.Parcelize
import kt.com.bilin.coin.api.ApiCode
import kt.com.bilin.coin.listener.OnCheckBean
import java.math.BigDecimal


/**
 * 统一数据封装类
 */
data class ResultBean<T>(var code: Int = SUCCESS, var msg: String? = null, var data: T? = null) {
    //    public static final int SERVICE_ERROR = 4011;//appId不存在,请检查appId是否填写正确
    //    public static final int SERVICE_ERROR = 4012;//authCode参数错误
    //    public static final int SERVICE_ERROR = 4031;//必要参数未上传
    companion object {
        const val SUCCESS = 200
        const val NOT_LOGIN = 401 //未登录或登录失效
        const val SERVICE_ERROR = 500 //服务器内部错误
    }

    val isOk: Boolean
        get() = code == SUCCESS
}

data class ApiData(
        var apiCode: ApiCode = ApiCode.START,
        var data: Any? = null,
        var apiName: String? = null,
        var throwable: Throwable? = null,
)

data class TabEntity(
        var title: String? = "",
        var selectedIcon: Int = 0,
        var unSelectedIcon: Int = 0,
        var tag: String? = null,
        var extend: String? = null,
) : CustomTabEntity {
    override fun getTabUnselectedIcon() = unSelectedIcon
    override fun getTabSelectedIcon() = selectedIcon
    override fun getTabTitle() = title

}

data class ImageUploadBean(
        var resId: Int = 0,
        var url: String? = null,
        var netUrl: String? = null,
        var originalFile: String = "",
        var md5: String? = null,
        var filePath: String? = null,
        var uploadFileName: String? = null,
        var position: Int = 0,
)

data class UploadDataBean(
        val originalFile: String = "",
        var compressFile: String = "",
)

data class PageBean<T>(
        val records: MutableList<T> = mutableListOf(),
        val total: Int = 0,
)

data class LoginBean(
        val csrfToken: String = "",
        val isNeedSecValid: Boolean = false,
        val loginSmsToken: String = "",
        val red: Double = 0.0,
        val userInfo: UserInfoBean = UserInfoBean(),
)

data class UserInfoBean(
        val canOtc: Boolean = false,
        val hasSetOtc: Boolean = false,
        val hasSetSafeWord: Boolean = false,
        val id: Int = 0,
        val inviteCode: String = "",
        val inviterId: Int = 0,
        val isLogin: Boolean = false,
        val isHasSafeWord: Boolean = false,
        val kycCancelReason: String = "",
        val kycStatus: String = "0",
        val mobile: String = "",
        val name: String = "",
        val no: String = "",
)

data class AppVersionBean(
        val latestVersion: String = "",
        val newVersion: String = "",
        val link: String = "",
        val content: String = "",
        val status: Int = 0,
)

data class BiLinAmountBean(
        val parentAmount: Double = 0.0,
        val selfAmount: Double = 0.0,
        val open: Boolean = false,
)

@Parcelize
data class UserMsgBean(
        val id: Int = 0,
        var isRead: Int = 0,
        val replyTitle: String = "反馈回复",
        val replyContent: String = "",
        val replyTime: String = "",
) : Parcelable

data class NotifyBean(
        val content: String = "",
        val title: String = "",
)

data class AppConfigBean(
        val ndpy: Int = 0,// 是否需要支付 0-不需要 1-需要
)

data class VersionBean(
        var latestVersion: String = "",
        val newVersion: String = "",
        val link: String = "",
        val content: String = "",
        var status: Int = 0,
)

data class HomeFunctionBean(
        val icon: Int = 0,
        val name: String = "",
)

data class WelfareActivityZoneBean(
        val icon: Int = 0,
        val title: String = "",
        val desc: String = "",
)

data class BusinessSchoolFunBean(
        val bgIcon: Int = 0,
        val icon: Int = 0,
        val name: String = "",
)

data class BusinessSchoolZXBean(
        val bgIcon: Int = 0,
        val title: String = "",
        val time: String = "",
        val link: String = "",
)

data class BannerBean(
        val createTime: String = "",
        val id: Int = 0,
        val jumpUrl: String = "",
        val picUrl: String = "",
        val remark: String = "",
        val updateTime: String = "",
        val version: Int = 0,
)

data class AnnounceBean(
        val content: String = "",
        val createTime: String = "",
        val id: Int = 0,
        val title: String = "",
        val type: Int = 0,
        val updateTime: String = "",
        val version: Int = 0,
) : IMarqueeItem {
    override fun marqueeMessage(): CharSequence {
        return if (title.length > 15) {
            title.substring(0, 12) + "..."
        } else title
    }
}

data class MoneyBean(
        val blq: String = "",
        val createTime: String = "",
        val gf: String = "",
        val jd: String = "",
        val jx: String = "",
        val level: String = "",
        val openChildCostBlq: Boolean = false,
        val updateTime: String = "",
        val version: String = "",
        val zz: String = "",
)

data class DigStatusBean(
        var digStatus: String = "",
        val hadAmount: String = "",
        val jdPerSecond: String = "",
        val remainSecond: String = "",
        val canSpeed: Boolean = false,
)

data class MyMillBean(
        var blDevice: BlDeviceBean = BlDeviceBean(),
        val createTime: String = "",
        val deviceId: String = "",
        val endTime: String = "",
        val id: String = "",
        val isAward: Boolean = false,
        val isOverDue: Boolean = false,
        val canAgain: Boolean = false,
        val totalAward: String = "",
        val updateTime: String = "",
        val userId: String = "",
        val validTime: String = "",
        val version: String = "",
        val workTime: String = "",
        val workTimeStr: String = "",
)

data class BlDeviceBean(
        var againStatus: String = "",
        val awardJd: String = "",
        val awardJx: String = "",
        val awardZz: String = "",
        val costJd: String = "",
        val createTime: String = "",
        val id: String = "",
        val imgUrl: String = "",
        val limitNum: String = "",
        val name: String = "",
        val perDayAward: String = "",
        val sort: String = "",
        val status: String = "",
        val updateTime: String = "",
        val validDay: String = "",
        val version: String = "",
        val workTime: String = "",
)

data class MillResourceBean(
        var awardJd: String = "",
        val awardJx: String = "",
        val awardZz: String = "",
        val costJd: String = "",
        val createTime: String = "",
        val id: String = "",
        val name: String = "",
        val sort: String = "",
        val status: String = "",
        val updateTime: String = "",
        val validDay: String = "",
        val version: String = "",
        val workTime: String = "",
        val perDayAward: String = "",
        val imgUrl: String = "",
        val workTimeStr: String = "",
        val validDayStr: String = "",
)

data class CZTaskBean(
        var adAwardStr1: String = "",
        val adAwardStr1Three: String = "",
        val adAwardStr1Two: String = "",
        val adAwardStr2: String = "",
        val adAwardStr2Three: String = "",
        val adAwardStr2Two: String = "",
        val childKycAwardStr1: String = "",
        val childKycAwardStr2: String = "",
        val directChildKycNum: String = "",
        val hasKyc: Boolean = false,
        val isAdOver: Boolean = false,
        val isAdOverThree: Boolean = false,
        val isAdOverTwo: Boolean = false,
        val kycAwardStr1: String = "",
        val kycAwardStr2: String = "",
        val perDayTimes: String = "",
        val perDayTimesThree: String = "",
        val perDayTimesTwo: String = "",
        val times: String = "",
        val timesThree: String = "",
        val timesTwo: String = "",
        val timesFour: String = "",
        val perDayTimesFour: String = "",
        val adAwardStr1Four: String = "",
        val adAwardStr2Four: String = "",
        val isAdOverFour: Boolean = false,
        val timesFive: String = "",
        val perDayTimesFive: String = "",
        val adAwardStr1Five: String = "",
        val adAwardStr2Five: String = "",
        val isAdOverFive: Boolean = false,
)

data class RechargeMoneyBean(
        val money: String = "",
        var check: Boolean = false,
        var jdc: String = "",
) : OnCheckBean {
    override fun showName() = money
    override fun check() = check
    override fun changeCheck(check: Boolean) {
        this.check = check
    }

    companion object {
        fun getRechargeMoneys() = mutableListOf(
                RechargeMoneyBean("30", true),
                RechargeMoneyBean("50"),
                RechargeMoneyBean("100"),
                RechargeMoneyBean("200"),
        )
    }
}

data class RechargeMoneyDetails(
        val fee: String = "0",
        val principal: String = "0",
        val total: String = "0",
)

data class RechargeInfoBean(
        val money: String = "",
        var principal: String = "0",
        var phone: String = "",
)

data class RechargeRecordBean(
        val amount: String = "0",
        val cardId: String = "",
        val cardName: String = "",
        val cardNum: String = "",
        val createTime: String = "",
        val fee: BigDecimal = BigDecimal("0"),
        val id: Int = 0,
        val orderCash: String = "",
        val orderNo: String = "",
        val payType: Int = 1,
        val phone: String = "",
        val reason: String = "",
        val sporderId: String = "",
        val status: Int = 0,
        val updateTime: String = "",
        val userId: Int = 0,
        val version: Int = 0,
) {
    fun getAmountText() = when (payType) {
        else -> "${amount}JDC"
    }

    //0充值中 1成功 9撤销
    fun getStatusText() = when (status) {
        1 -> "成功"
        9 -> "撤销"
        else -> "充值中"
    }
}

data class BSAudioBean(
        val title: String = "",
        val link: String = "",
        val time: String = "",
        var check: Boolean = false,
) : OnCheckBean {
    override fun showName() = title
    override fun check() = check
    override fun changeCheck(check: Boolean) {
        this.check = check
    }
}

data class MaterialShareBean(
        val path: String,
        val width: Int,
        val height: Int,
)

data class BSVideoBean(
        val title: String = "",
        val link: String = "",
        val cover: Int = 0,
        val time: String = "",
)

data class LotteryNumBean(
        val reaminNum: Int = 0,
)

data class LotteryAwardBean(
        val awardId: Int = 0,
        val awardDesc: String = "",
)

data class InviteBean(
        val inviteCode: String = "",
        val link: String = "",
)

/**
 * 一等奖 1000
二等奖 2000
三等奖 3000
四等奖 4000
贡献奖 5000 ----  奖励1个工分
比邻五福 6000 -- 这个又包括 5种类型
6.1 富贵 6001
6.2 健康 6002
6.3 平安 6003
6.4 幸福 6004
6.5 智慧 6005
 */
enum class LuckyTurntableEnum(
        val id: Int,
        val pisition: Int,
        val luckyName: String,
) {
    ONE(1000, 1, "一等奖"),
    THANK(7000, 2, "感谢参与"),
    FIVE_BLESSINGS(6000, 3, "比邻五福"),
    FIVE_BLESSINGS_1(6001, 3, "富贵福"),
    FIVE_BLESSINGS_2(6002, 3, "健康福"),
    FIVE_BLESSINGS_3(6003, 3, "平安福"),
    FIVE_BLESSINGS_4(6004, 3, "幸福福"),
    FIVE_BLESSINGS_5(6005, 3, "智慧福"),
    WORK_SCORE(5000, 4, "贡献奖"),
    FOUR(4000, 5, "四等奖"),
    THREE(3000, 6, "三等奖"),
    TWO(2000, 7, "二等奖"),
}

data class LotteryBean(
        val awardDesc: String = "",
        val awardId: Int = 0,
        val createTime: String = "",
        val id: Int = 0,
        val status: Int = 0,
        val type: Int = 0,
        val updateTime: String = "",
        val userId: Int = 0,
        val version: Int = 0,
)

data class CplBean(
        val name: String = "",
        val url: String = "",
)